package com.dayouzi.crawler_monitor.pojo.entity;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import org.springframework.util.StringUtils;

/**
 * 服务器ip对应的xxl-job的服务器id
 */
@Getter
@AllArgsConstructor
@ToString
public enum MachineEnum {

    MACHINE241("192.168.1.241", 2),
    MACHINE181("192.168.1.181", 5),
    MACHINE192("192.168.1.192", 6),
    MACHINE213("192.168.1.213", 7),
    MACHINE196("192.168.1.196", 8),
    MACHINE211("192.168.1.211", 9),
    MACHINE208("192.168.1.208", 10),
    MACHINE191("192.168.1.191", 11),
    MACHINE195("192.168.1.195", 12),
    MACHINE59("192.168.1.59", 13),
    MACHINE60("192.168.1.60", 14),
    MACHINE221("192.168.1.221", 15),
    MACHINE225("192.168.1.225", 16),
    MACHINE224("192.168.1.224", 17);

    private String ip;

    private Integer id;

    public static Integer getMachineId(String ip) {
        for (MachineEnum machine : MachineEnum.values()) {
            if (machine.ip.equals(ip)) {
                return machine.id;
            }
        }
        return 0;
    }


}
